Add options for NonEq relaxation timescales as functions of N and T#676
Add options for NonEq relaxation timescales as functions of N and T#676oalcabes wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #676 +/- ##
==========================================
- Coverage 92.02% 91.62% -0.41%
==========================================
Files 54 54
Lines 2321 2341 +20
==========================================
+ Hits 2136 2145 +9
- Misses 185 196 +11
🚀 New features to boost your workflow:
|
cf55a81 to
9346e0c
Compare
| MicrophysicsNonEq.τ_relax | ||
| MicrophysicsNonEq.conv_q_vap_to_q_lcl_icl | ||
| MicrophysicsNonEq.conv_q_vap_to_q_lcl_MM2015 | ||
| MicrophysicsNonEq.conv_q_vap_to_q_icl_MM2015 |
There was a problem hiding this comment.
Do we still want to keep MicrophysicsNonEq.conv_q_vap_to_q_icl_MM2015?
There was a problem hiding this comment.
Ideally we would keep "MicrophysicsNonEq.conv_q_vap_to_q_lcl_MM2015" and "MicrophysicsNonEq.conv_q_vap_to_q_icl_MM2015" and delete "MicrophysicsNonEq.conv_q_vap_to_q_lcl_icl_MM2015" - I was leaving it now for backwards compatibility but if we're okay with a breaking release I can just delete it
|
|
||
| # Using same limiter as ClimaAtmos for now | ||
| # Not sure why, but without intermediate storing of the tendencies for the | ||
| # if/else branch this code segfaults on julia v1.11 (works fine on v1.10) |
There was a problem hiding this comment.
No idea. But I have seen this before too :/
0e64b5e to
ab706fb
Compare
0d2eda2 to
9bffcec
Compare
caabc3d to
22cafcc
Compare
|
Hi @trontrytel and @sajjadazimi -- I'm coming back to this PR. The PR is doing three main things, namely: (1) refactors the NonEquilibrium parameterization to accept tau as an argument rather than calculating it inside of the function (2) introduce a version of tau_i calculated from Frostenberg et. al. (2023) and (3) add parcel and documentation examples for the Frostenberg option. For now I would like to focus most on the refactoring change -- if you all like it we can keep it in this PR, but if you have major comments perhaps I'll do it in a separate PR. |
|
I specifically desire comments on src/BulkMicrophysicsTendencies.jl |
| if noneq_scheme isa NonEq_Constant | ||
| τₗ = lcl.τ_relax | ||
| τᵢ = icl.τ_relax | ||
| elseif noneq_scheme isa NonEq_N # this assumes we're using the Frostenberg parameterization for τᵢ |
There was a problem hiding this comment.
To decide: do we want to have liquid calculated like this as well, or just keep the ice relaxation timescale changing instead?
| - `warm_rain` | ||
| - `sb`: SB2006 parameters | ||
| - `aps`: air property parameters % OLIVIA CLEAN THIS UP -- also missing ice??? | ||
| - `noneq_scheme` Type of NonEquilibrium scheme to use (NOT NECESSARILY NEEDED BUT KEEP IT FOR THE FUTURE) |
There was a problem hiding this comment.
currently passing this flag but not using it yet -- may not be necessary if we decide to keep tau_l always constant for now and only change tau_i
22cafcc to
019d9a7
Compare
sajjadazimi
left a comment
There was a problem hiding this comment.
Thank you for refactoring and adding the options for relaxation time scale. It looks good overall. I left a few minor comments.
| \end{equation} | ||
| ``` | ||
|
|
||
| where ``q_c`` is the mass of condensate and ``ρ_c`` is the density of the condensate (either liquid or water). Then, we calculate the relaxation timescale: |
| N_i(T) = ln(-(b \cdot T)^9 \times 10^{-9}) | ||
| ``` | ||
|
|
||
| ``\sigma^2`` is the variance, ``a`` and ``b`` are coefficients. The parameters defined in [Frostenberg2023](@cite) for marine data sets are ``\sigma=1.37``, ``a=1`` m``^3``, ``b=1``/C. |
| """ | ||
| NonEq Scheme | ||
|
|
||
| Abstract type for NonEquilibrium microphysics parameterizations. Namely, | ||
| this scheme specifies how to set the relaxation timescales (τₗ, τᵢ) for | ||
| liquid condensation/evaporation and ice deposition/sublimation. | ||
| NonEq_Constant sets τₗ and τᵢ are determined by the τ_relax arguments in | ||
| lcl and icl, whereas NonEq_N calculates τₗ and τᵢ from liquid and ice | ||
| number concentration. | ||
| """ | ||
| abstract type NonEqScheme end | ||
| struct NonEq_Constant <: NonEqScheme end | ||
| struct NonEq_N <: NonEqScheme end | ||
|
|
There was a problem hiding this comment.
Maybe it's better to move this struct definition to NoneqMicrophysics
| ::Microphysics1Moment, | ||
| noneq_scheme::NonEqScheme, |
There was a problem hiding this comment.
noneq_scheme could be an element of Microphysics1Moment. I see Microphysics1Moment as an umbrella that could define what submodels should be including the non equilibrium scheme.
This is not a strong opinion, so ignore if it's not possible.
There was a problem hiding this comment.
I agree. Otherwise we will start to have to carry more parameters in Microphysics1Moment than what we actually need for a single simulation
| if noneq_scheme isa NonEq_Constant | ||
| τₗ = lcl.τ_relax | ||
| τᵢ = icl.τ_relax | ||
| elseif noneq_scheme isa NonEq_N | ||
| τₗ = CMNonEq.τ_N(q_icl, N_lcl, lcl.ρw, aps.D_vapor) | ||
| τᵢ = CMNonEq.τ_Frostenberg(icl, aps, ip, q_icl, T) | ||
| end |
There was a problem hiding this comment.
For code readability, you could dispatch over noneq_scheme and return the tuple of tau_l and tau_i
| - `dn_rai_dt`: Rain number tendency (1/kg/s) | ||
| """ | ||
| @inline function warm_rain_tendencies_2m(warm_rain, tps, T, q_tot, q_lcl, q_rai, q_ice, ρ, n_lcl, n_rai) | ||
| @inline function warm_rain_tendencies_2m(warm_rain, noneq_scheme, tps, T, q_tot, q_lcl, q_rai, q_ice, ρ, n_lcl, n_rai) |
There was a problem hiding this comment.
same as 1m: noneq_scheme could live under warm_rain model
| """ | ||
| @inline function bulk_microphysics_tendencies( | ||
| ::Microphysics2Moment, mp::CMP.Microphysics2MParams{WR, Nothing}, tps, | ||
| ::Microphysics2Moment, noneq_scheme::NonEqScheme, mp::CMP.Microphysics2MParams{WR, Nothing}, tps, |
| @inline τ_relax(p::CMP.CloudLiquid) = p.τ_relax | ||
| @inline τ_relax(p::CMP.CloudIce) = p.τ_relax |
There was a problem hiding this comment.
Here, you could dispatch over non-eq method too
|
|
||
| ### Liquid and ice relaxation timescales as functions of number concentration | ||
|
|
||
| We also provide functionality to set the relaxation timescales of liquid and ice, ``\tau_l`` and ``\tau_i``, as functions of cloud droplet number concentrations ``N_l`` and ``N_i`` following [MorrisonGrabowski2008_supersat](@cite) and [MorrisonMilbrandt2015](@cite). First, we approximate average radius of droplets from mass and number: |
There was a problem hiding this comment.
| We also provide functionality to set the relaxation timescales of liquid and ice, ``\tau_l`` and ``\tau_i``, as functions of cloud droplet number concentrations ``N_l`` and ``N_i`` following [MorrisonGrabowski2008_supersat](@cite) and [MorrisonMilbrandt2015](@cite). First, we approximate average radius of droplets from mass and number: | |
| We also provide functionality to set the relaxation timescales of liquid and ice, ``\tau_l`` and ``\tau_i``, as functions of cloud droplet and ice crystal number concentrations ``N_l`` and ``N_i`` following [MorrisonGrabowski2008_supersat](@cite) and [MorrisonMilbrandt2015](@cite). First, we approximate average radius of droplets from mass and number: |
Draft PR to make new versions of the NonEq scheme, namely tau(T) and tau(N) functionality. Still need to review docs and think carefully about testing, but I'd love comments and thoughts on the PR! This may break atmos as I've made changes to the bulk_microphysics_tendency function.